home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 1
/
Nebula One.iso
/
Misc
/
PowerGloveInspector
/
Source
/
PowerGloveView.m
< prev
next >
Wrap
Text File
|
1995-06-12
|
1KB
|
56 lines
#import "PowerGloveView.h"
#import <math.h>
@implementation PowerGloveView
/* Over-ridden methods */
- initFrame:(const NXRect *)frameRect
{
[super initFrame:frameRect];
[self setDrawSize:256.0 :256.0];
[self setDrawOrigin:-128.0 :-128.0];
[self setOpaque:YES];
return self;
}
- drawSelf:(const NXRect *)rects :(int)rectCount
{
/* Get position and rotation of glove */
float x = [xField floatValue];
float y = [yField floatValue];
float z = [zField floatValue];
float angle = [rollField floatValue];
/* Erase previous view */
PSsetlinewidth(0.15);
PSsetgray(NX_WHITE);
NXRectFill(&bounds);
/* Draw empty half-circle */
PSmoveto(x,y);
PSarc(x,y,fabs(z),-angle,180.0-angle);
PSsetgray(NX_BLACK);
PSstroke();
/* Draw filled half-circle */
PSarc(x,y,fabs(z),180.0-angle,-angle);
if (z<0.0) PSsetgray(NX_LTGRAY);
PSfill();
/* Draw cross-hairs and frame */
PSsetgray(NX_BLACK);
PSmoveto(-128.0,0.0);
PSlineto(128.0,0.0);
PSmoveto(0.0,-128.0);
PSlineto(0.0,128.0);
PSstroke();
NXFrameRect(&bounds);
[window flushWindow];
return self;
}
@end